<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:ppro="http://packetpro.de/jsf/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:ui="http://java.sun.com/jsf/facelets" version="2.0">
	<ui:composition template="/layout/templates/common.xhtml">
		<ui:define name="pageTitle">
			<h:outputText value="#{msg.input_header}" />
		</ui:define>
		<ui:define name="pageHeader">
			<h3 align="center"><h:outputText value="#{msg.sprachliste}" /></h3>
			<h3 align="center"><h:outputText styleClass="do_something"
				value="#{translationMsgId}" /></h3>
		</ui:define>
		<ui:define name="body">
			<f:view contentType="text/html">
				<p />
				<h:commandButton styleClass="image" image="/layout/images/back.png"
					action="#{langElementBean.prevLangElement}" />
				<h:graphicImage value="/layout/images/spacer.gif" width="100"
					height="1" />
				<h:commandButton styleClass="image" image="/layout/images/up2.png"
					action="goToIndex" />
				<h:graphicImage value="/layout/images/spacer.gif" width="100"
					height="1" />
				<h:commandButton styleClass="image" image="/layout/images/forward.png"
					action="#{langElementBean.nextLangElement}" />
				<p />
				<h:panelGroup rendered="#{changed=='1'}">
					<h:outputText styleClass="dauerhaftSpeichern"
						value="#{msg.dauerhaftSpeichern}" />
					<h:graphicImage value="/layout/images/spacer.gif" width="10"
						height="1" />
					<h:commandButton value="#{msg.saveButton}"
						action="#{xmlService.saveXML}" />
				</h:panelGroup>
				<p />
				<h:form id="editForm">
					<!-- Tabelle mit Sprachen -->
					<h:dataTable id="lang" value="#{langElementBean.langElements}"
						var="langElement" styleClass="outer"
						columnClasses="firstColumn,secondColumn">


						<!-- Sprachenspalte -->
						<h:column>
							<f:facet name="header">
								<h:outputText value="#{msg.sprachcolumn_header}" />
							</f:facet>
							<h:outputText value="#{langElement.lang}" />
						</h:column>

						<!-- Parameterspalte -->
						<h:column>
							<f:facet name="header">
								<h:outputText value="#{msg.parametercolumn_header}" />
							</f:facet>

							<h:dataTable value="#{langElement.parameterList}" var="paramItem"
								styleClass="inner"
								columnClasses="firstColumnInner,secondColumnInner,thirdColumnInner">

								<h:column>
									<h:outputText value="#{paramItem.typ}" />
									<h:graphicImage value="/layout/images/spacer.gif" width="100"
										height="1" />
								</h:column>

								<h:column>
									<h:outputText value="#{paramItem.value}"
										rendered="#{paramItem.typ=='Paragraph'}" />
									<h:commandButton rendered="#{paramItem.typ=='Include'}"
										styleClass="do_something" action="edit"
										actionListener="#{langElementBean.selectTranslationElement}"
										value="#{paramItem.value}">
										<f:attribute name="transmsgId" value="#{paramItem.value}" />
									</h:commandButton>

									<f:facet name="footer">

										<h:inputTextarea rows="3" cols="120"
											rendered="#{langElement.parameterList[0].typ!='Include' and !(empty langElement.parameterList)}"
											value="#{langElement.newValue}" />

									</f:facet>
								</h:column>

								<h:column>
									<h:panelGrid columns="2"
										rendered="#{!empty langElement.parameterList}"
										styleClass="innerGrid" columnClasses="thirdColumnInner">
										<h:panelGrid columns="3"
											rendered="#{langElement.parameters!=1}">
											<h:commandButton
												rendered="#{langElement.parameters!=(paramItem.id + 1)}"
												styleClass="image"
												image="/layout/images/down.png" action="edit"
												actionListener="#{langElementBean.moveDownPara}">
												<f:attribute name="lang" value="#{langElement.lang}" />
												<f:attribute name="delPara" value="#{paramItem.value}" />
											</h:commandButton>
											<h:graphicImage
												rendered="#{langElement.parameters==(paramItem.id + 1)}"
												value="/layout/images/spacer.gif" width="14" height="1" />
											<h:graphicImage value="/layout/images/spacer.gif" width="1"
												height="1" />
											<h:commandButton rendered="#{paramItem.id!=0}"
												styleClass="image"
												image="/layout/images/up.png" action="edit"
												actionListener="#{langElementBean.moveUpPara}">
												<f:attribute name="lang" value="#{langElement.lang}" />
												<f:attribute name="delPara" value="#{paramItem.value}" />
											</h:commandButton>
										</h:panelGrid>
										<h:commandButton
											onclick="if (!confirm('Sind Sie sicher ?')) return false"
											action="edit" actionListener="#{langElementBean.delPara}"
											value="#{langElement.parameterList[0].typ=='Include' ? msg.deleteIncludeButton : msg.deleteParagraphButton}">
											<f:attribute name="lang" value="#{langElement.lang}" />
											<f:attribute name="delPara" value="#{paramItem.value}" />
										</h:commandButton>
									</h:panelGrid>
									<f:facet name="footer">
										<h:panelGrid styleClass="innerGrid"
											columnClasses="thirdColumnInner">
											<h:commandButton value="#{msg.addParagraphButton}"
												rendered="#{langElement.parameterList[0].typ!='Include' and !(empty langElement.parameterList)}"
												action="edit" actionListener="#{langElementBean.addPara}"
												styleClass="inputRight">
												<f:attribute name="lang" value="#{langElement.lang}" />
												<f:attribute name="newValue" value="#{langElement.newValue}" />
											</h:commandButton>
										</h:panelGrid>
									</f:facet>
								</h:column>

							</h:dataTable>
							<h:panelGrid rendered="#{empty langElement.parameterList}"
								columns="3" styleClass="inner"
								columnClasses="firstColumnInner,secondColumnInner,thirdColumnInner">
								<h:graphicImage value="/layout/images/spacer.gif" width="100"
									height="1" />
								<h:inputTextarea rows="3" cols="120"
									value="#{langElement.newValue}" />
								<h:panelGrid styleClass="innerGrid"
									columnClasses="thirdColumnInner">
									<h:commandButton value="#{msg.addParagraphButton}"
										action="edit" actionListener="#{langElementBean.addPara}">
										<f:attribute name="lang" value="#{langElement.lang}" />
										<f:attribute name="newValue" value="#{langElement.newValue}" />
									</h:commandButton>
									<h:commandButton value="#{msg.addIncludeButton}" action="edit"
										actionListener="#{langElementBean.addInc}">
										<f:attribute name="lang" value="#{langElement.lang}" />
										<f:attribute name="newValue" value="#{langElement.newValue}" />
									</h:commandButton>
								</h:panelGrid>
							</h:panelGrid>
						</h:column>
					</h:dataTable>
					<br></br>
					<h:panelGroup rendered="#{!empty langElementBean.emptyLangs}">
						<h:selectOneMenu value="#{langElementBean.selectedLang}">
							<f:selectItems value="#{langElementBean.emptyLangs}" />
						</h:selectOneMenu>
						<h:graphicImage value="/layout/images/spacer.gif" width="5"
							height="1" />
						<h:commandButton value="#{msg.addSpracheButton}"
							action="#{langElementBean.addSprache}" />

						<p />
					</h:panelGroup>


				</h:form>
			</f:view>
		</ui:define>
	</ui:composition>
</jsp:root>